package com.hhsjdesign.dynamicui.core.property.item

import android.widget.ImageView

/**
 * 图片视图属性
 */
class ImageViewProperty(var scaleType: Int, funCode: String) :
    FunctionViewProperty(funCode) {

    companion object {
        const val ScaleType_CENTER_CROP = 0
        const val ScaleType_CENTER_INSIDE = 1
        const val ScaleType_FIT_XY = 2
        const val ScaleType_FIT_WIDTH = 3
        const val ScaleType_FIT_HEIGHT = 4

        @JvmStatic
        fun scaleType(scaleType: Int): ImageView.ScaleType {
            return when (scaleType) {
                ScaleType_CENTER_CROP -> ImageView.ScaleType.CENTER_CROP
                ScaleType_CENTER_INSIDE -> ImageView.ScaleType.CENTER_INSIDE
                ScaleType_FIT_XY -> ImageView.ScaleType.FIT_XY
                ScaleType_FIT_WIDTH -> ImageView.ScaleType.CENTER_INSIDE
                ScaleType_FIT_HEIGHT -> ImageView.ScaleType.CENTER_INSIDE
                else -> ImageView.ScaleType.CENTER_CROP
            }
        }
    }

    fun scaleType(): ImageView.ScaleType {
        return scaleType(scaleType)
    }
}